/* --------------------------Usercode Section------------------------ */
   
import java_cup.runtime.*;
      
%%
   
/* -----------------Options and Declarations Section----------------- */
   
%class Scanner
%line
%column
%cup
   

%{   
    private Symbol symbol(int type) {
        return new Symbol(type, yyline, yycolumn);
    }
    
    private Symbol symbol(int type, Object value) {
        return new Symbol(type, yyline, yycolumn, value);
    }
%}
   

/*
  Macro Declarations
  
  These declarations are regular expressions that will be used latter
  in the Lexical Rules Section.  
*/

letter          = [A-Za-z]
digit           = [0-9]
alphanumeric    = {letter}|{digit}
other_id_char   = [_]
identifier      = {letter}
integer         = {digit}*
char            = '.'
leftbrace       = \{
rightbrace      = \}
nonrightbrace   = [^}]
comment_body    = {nonrightbrace}*
comment         = {leftbrace}{comment_body}{rightbrace}
whitespace      = [ \n\t]
   
%%
/* ------------------------Lexical Rules Section---------------------- */
  
programa	{ return symbol(sym.programa); }  
se 		{ return symbol(sym.se); }  
entao 		{ return symbol(sym.entao); }  
senao 		{ return symbol(sym.senao); }  
var		{ return symbol(sym.var); }
inicio		{ return symbol(sym.inicio); }  
fim		{ return symbol(sym.fim); }  
inteiro		{ return symbol(sym.inteiro); }
booleano	{ return symbol(sym.booleano); }
imprime		{ return symbol(sym.imprime); }
verdadeiro	{ return symbol(sym.verdadeiro); }
falso		{ return symbol(sym.falso); }
";"		{ return symbol(sym.ptvirg); }
":"		{ return symbol(sym.doispt); }
"+"		{ return symbol(sym.soma); }
"-"		{ return symbol(sym.subt); }
"*"		{ return symbol(sym.mult); }
"/"		{ return symbol(sym.divi); }
"="		{ return symbol(sym.igual); }
or		{return symbol(sym.or);}
xor		{return symbol(sym.xor);}
and		{return symbol(sym.and);}
not		{return symbol(sym.not);}
{identifier}	{ return symbol(sym.identificador, new String(yytext()));}
{integer}	{ return symbol(sym.intnum, new Integer(yytext()));}
{comment}       { /* For this stand-alone lexer, print out comments. */
                  System.out.println("Recognized comment: " + yytext()); }
{whitespace}    { /* Ignore whitespace. */ }
.|\n               {}// System.out.println("Illegal char, '" + yytext() + "' line: " + yyline + ", column: " + yychar); }
